home *** CD-ROM | disk | FTP | other *** search
Wrap
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' This file can be replaced in one of the future versions, ' so please if you want to modify it, make a copy, do your ' modifications in that copy and change Scripts.ini file ' appropriately. ' If you do not do this, you will lose all your changes in ' this script when you install a new version of MediaMonkey ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' MediaMonkey statistics script ' This script was adapted by TheRocket from the ' MediaMonkey Web Extension (MMWBE) also made by myself. ' Coded in December 2004 - January 2005. ' Thanks to Rusty for his suggestions and letting me ' include this script into the next versions! ' It shows globaly the songs you have in your MediaMonkey, ' and what you listen often. It can be a great way to ' find what type of music a person likes. ' Send us new statistics ideas in the MediaMonkey Forum! ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Option Explicit Public booStyleOn Const intTopCount = 10 Const mmAnchorRight = 4 Const mmAnchorBottom = 8 Const mmAlignTop = 1 Const mmAlignBottom = 2 Const mmAlignClient = 5 Const mmListDropdown = 2 Const mmFormScreenCenter = 4 Sub ShowStats() Dim UI Dim Form Dim Foot Dim Btn Dim Btn2 Dim WB Dim doc Dim DlgWidth Set UI = SDB.UI DlgWidth = 500 ' Create the window to be shown Set Form = UI.NewForm Form.Common.SetRect 50, 50, DlgWidth, 400 Form.Common.MinWidth = 200 Form.Common.MinHeight = 150 Form.FormPosition = mmFormScreenCenter Form.Caption = SDB.Localize("MediaMonkey Music Library Statistics") Form.StayOnTop = True ' Create a panel at the bottom of the window Set Foot = UI.NewPanel(Form) Foot.Common.Align = mmAlignBottom Foot.Common.Height = 35 ' Create a button that saves the report Set Btn2 = UI.NewButton(Foot) Btn2.Caption = SDB.Localize("&Save as...") Btn2.Common.SetRect DlgWidth - 255, 6, 150, 24 'Btn2.Common.Hint = SDB.Localize("Save this report") Btn2.Common.Anchors = mmAnchorRight + mmAnchorBottom Btn2.UseScript = Script.ScriptPath Btn2.OnClickFunc = "SaveAs" ' Create a button that closes the window Set Btn = UI.NewButton(Foot) Btn.Caption = SDB.Localize("&Close") Btn.Common.SetRect DlgWidth - 100, 6, 85, 24 'Btn.Common.Hint = SDB.Localize("Close this report") Btn.Common.Anchors = mmAnchorRight + mmAnchorBottom Btn.UseScript = Script.ScriptPath Btn.OnClickFunc = "OnClose" ' Create a web browser component Set WB = UI.NewActiveX(Form, "Shell.Explorer") WB.Common.Align = mmAlignClient ' Fill all client rectangle WB.Common.ControlName = "WB" Form.SavePositionName = "StatisticsWindow" Form.Common.Visible = True ' Only show the form, don't wait for user input SDB.Objects("Statistics") = Form ' Save reference to the form somewhere, otherwise it would simply disappear WB.SetHTMLDocument( BuildReport(false)) End Sub Sub OnClose(Btn) SDB.Objects("Statistics") = Nothing ' Remove the last reference to our form which also causes it to disappear End Sub Function Style() booStyleOn = Not booStyleOn If booStyleOn Then Style = "" Else Style = " class=""Dark""" End If End Function Public Function FormatFileSize(intFileLength) Dim strSize strSize = SDB.Localize("Bytes") If intFileLength >= 1024 Then intFileLength = Round(intFileLength / 1024) strSize = SDB.Localize("KB") End If If intFileLength >= 1024 Then intFileLength = Round(intFileLength / 1024, 2) strSize = SDB.Localize("MB") End If If intFileLength >= 1024 Then intFileLength = Round(intFileLength / 1024, 2) strSize = SDB.Localize("GB") End If If intFileLength >= 1024 Then intFileLength = Round(intFileLength / 1024, 2) strSize = SDB.Localize("TB") End If FormatFileSize = intFileLength & " " & strSize End Function Public Function FormatTime(intLength) Dim strLength, intLengthHeures, intLengthMinutes, intLengthSecondes, datLength Dim strTimeSeparator 'Find out the current time separator (for some locales, it is a period) datLength = TimeSerial(11, 11, 11) strLength = FormatDateTime(datLength,vbshorttime) strTimeSeparator = left(replace(strLength,"1",""),1) intLength = CCur(intLength / 1000) intLengthHeures = Int(intLength / 60 / 60) intLengthMinutes = Int(intLength / 60) Mod 60 intLengthSecondes = intLength Mod 60 strLength = intLengthHeures & strTimeSeparator if intLengthMinutes < 10 then strLength = strLength & "0" strLength = strLength & intLengthMinutes & strTimeSeparator if intLengthSecondes < 10 then strLength = strLength & "0" strLength = strLength & intLengthSecondes FormatTime = strLength End Function ' escape XML string Function MapXML(srcstring) srcstring = Replace(srcstring, "&", "&") srcstring = Replace(srcstring, "<", "<") srcstring = Replace(srcstring, ">", ">") Dim i i=1 While i<=Len(srcstring) If (AscW(Mid(srcstring, i, 1))>127) Then srcstring = Mid( srcstring, 1, i-1)+""+CStr( AscW( Mid( srcstring, i, 1)))+";"+Mid( srcstring, i+1, Len(srcstring)) End If i=i+1 WEnd If srcstring="" Then srcstring = " " End IF MapXML = srcstring End Function Function ExtractText(ByVal inText, ByVal inDebut, ByVal inFin) Dim pos1 Dim pos2 pos1 = InStr(1, inText, inDebut) If pos1 = 0 Then pos1 = 1 Else pos1 = pos1 + Len(inDebut) pos2 = InStr(pos1, inText, inFin) If pos2 < pos1 Then pos2 = Len(inText) + 1 ExtractText = Mid(inText, pos1, pos2 - pos1) End Function Function ExtractTextInvert(ByVal inText, ByVal inDebut, ByVal inFin) ExtractTextInvert = StrReverse(ExtractText(StrReverse(inText), StrReverse(inDebut), StrReverse(inFin))) End Function function ExtractPathName(strPath) dim StrTemp StrTemp= ExtractTextInvert(strPath,"","\") ExtractPathName = Left(strPath, Len(strPath) - Len(StrTemp)) end function Function ShowRating(intNo, booForExport) Dim a If intNo = -1 Then ShowRating = " " ElseIf intNo = 0 Then if not booForExport then ShowRating = "<img src=""" & ExtractPathName(script.scriptpath) & "\bomb.png"" border=""0"" width=""10"" height=""11"">" else ShowRating = "0" end if Else ' ShowRating = round(intNo / 10) / 2 For a = 20 To intNo Step 20 if not booForExport then ShowRating = ShowRating & "<img src=""" & ExtractPathName(script.scriptpath) & "\star.png"" width=""10"" height=""11"" border=""0"">" else ShowRating = ShowRating & "*" end if Next End If If (intNo Mod 20) >= 10 Then if not booForExport then ShowRating = ShowRating & "<img src=""" & ExtractPathName(script.scriptpath) & "\half-star.png"" width=""10"" height=""11"" border=""0"">" else ShowRating = ShowRating & """ end if End If End Function function NoNull(VarCanBeNull, varWhenNull) if isnull(varcanbenull) then NoNull = varWhenNull else NoNull = varCanBeNull end if end function Sub SaveAS(Btn) Dim strExportTo Dim booSave Dim fout Dim fso With SDB.CommonDialog .DefaultExt = "html" '.FileName = SDB.Localize("Save as...") .Filter = "HTML (*.htm)|*.htm|All files (*.*)|*.*" .Title = SDB.Localize("Exporting...") .InitDir = SDB.IniFile.StringValue("Scripts", "LastExportStatsDir") .ShowSave booSave = .Ok strExportTo = .FileName End With if booSave then ' Connect to the FileSystemObject Set fso = SDB.Tools.FileSystem ' Create the output file Set fout = fso.CreateTextFile(strExportTo, True) ' Write header line fout.Write BuildReport(true) ' Close the output file and finish fout.Close set fout = nothing set fso = nothing end if end sub Function BuildReport(booForExport) Dim qryStats Dim strSQL Dim intArtistsCount Dim intArtistsCountPlayed Dim intAlbumCount Dim intAlbumsCountPlayed Dim intGenreCount Dim intLength Dim intFileLength Dim intLengthPlayed Dim intFileLengthPlayed Dim intYearCount Dim intPlaylistCount Dim intPlayed Dim intAllCount Dim strOut strOut = "" 'Building base page strOut = strOut & "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbcrlf strOut = strOut & "<html>" & vbcrlf strOut = strOut & " <head>" & vbcrlf strOut = strOut & " <title>" & SDB.Localize("MediaMonkey Music Library Statistics") & "</title>" & vbcrlf strOut = strOut & " </head>" & vbcrlf strOut = strOut & "<STYLE TYPE=text/css>" & vbcrlf strOut = strOut & "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}" & vbcrlf strOut = strOut & "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:left}" & vbcrlf strOut = strOut & "P{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000;}" & vbcrlf strOut = strOut & "TH{font-family:'Verdana',sans-serif; font-size:10pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}" & vbcrlf strOut = strOut & "TD{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}" & vbcrlf strOut = strOut & "TR.dark{background-color:#EEEEEE}" & vbcrlf strOut = strOut & "TR.aleft TH{text-align:left}" & vbcrlf strOut = strOut & "</STYLE>" & vbcrlf strOut = strOut & " <body>" & vbcrlf strOut = strOut & " <H1>" & SDB.Localize("MediaMonkey Music Library Statistics") & "</H1>" & vbcrlf 'Totals strSQL = "SELECT Count(*) As Nombre FROM Artists WHERE ID <> 0" Set qryStats = SDB.Database.OpenSQL(strSQL) intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0)) strSQL = "SELECT Count(*) AS CountOfID FROM (SELECT Artists.ID FROM (Artists INNER JOIN Songs ON Artists.ID = Songs.IDArtist) INNER JOIN Played ON Songs.ID = Played.IdSong GROUP BY Artists.ID)" Set qryStats = SDB.Database.OpenSQL(strSQL) intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0)) strSQL = "SELECT Count(*) As Nombre FROM Albums WHERE ID <> 0" Set qryStats = SDB.Database.OpenSQL(strSQL) intAlbumCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0)) strSQL = "SELECT Count(*) As CountOfID FROM (SELECT Albums.ID FROM albums INNER JOIN (Songs INNER JOIN Played ON Songs.ID = Played.IdSong) ON Albums.ID = Songs.IDAlbum GROUP BY Albums.ID)" Set qryStats = SDB.Database.OpenSQL(strSQL) intAlbumsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0)) strSQL = "SELECT Count(QryTemp.IDGenre) AS Nombre FROM (SELECT Genres.IDGenre FROM Songs INNER JOIN Genres ON Songs.Genre = Genres.IDGenre GROUP BY Genres.IDGenre) as QryTemp" Set qryStats = SDB.Database.OpenSQL(strSQL) intGenreCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0)) strSQL = "SELECT Count(QryTemp.Year) AS Nombre FROM (SELECT Songs.Year FROM Songs GROUP BY Songs.Year HAVING Songs.Year <> -1) as QryTemp" Set qryStats = SDB.Database.OpenSQL(strSQL) intYearCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0)) strSQL = "SELECT Count(*) As Nombre FROM PlayLists WHERE (ISAutoPlayList is null)" Set qryStats = SDB.Database.OpenSQL(strSQL) intPlaylistCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0)) strSQL = "SELECT Count(*) As Nombre FROM Played" Set qryStats = SDB.Database.OpenSQL(strSQL) intPlayed = CLng(NoNull(qryStats.ValueByName("Nombre"),0)) strSQL = "SELECT Count(*) As Nombre, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM Songs" Set qryStats = SDB.Database.OpenSQL(strSQL) intAllCount = CLng(NoNull(qryStats.StringByName("Nombre"),0)) intLength = CCur(NoNull(qryStats.ValueByName("TotalLength"),0)) intFileLength = CCur(NoNull(qryStats.ValueByName("TotalFileLength"),0)) strSQL = "SELECT Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong" Set qryStats = SDB.Database.OpenSQL(strSQL) intLengthPlayed = CCur(NoNull(qryStats.ValueByName("TotalLength"),0)) intFileLengthPlayed = CCur(NoNull(qryStats.ValueByName("TotalFileLength"),0)) strOut = strOut & " <p/>" & vbcrlf strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""3"">" & SDB.Localize("Totals") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft""><th>" & SDB.Localize("Type") & "</th><th>" & SDB.Localize("Library") & "</th><th>" & SDB.Localize("Played") & "</th></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Artists") & "</td><td>" & intArtistsCount & "</td><td>" & intArtistsCountPlayed & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Albums") & "</td><td>" & intAlbumCount & "</td><td>" & intAlbumsCountPlayed & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Genres") & "</td><td>" & intGenreCount & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Years") & "</td><td>" & intYearCount & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Playlists") & "</td><td>" & intPlaylistCount & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks") & "</td><td>" & intAllCount & "</td><td>" & intPlayed & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Length") & " (h:mm:ss)</td><td>" & FormatTime(intLength) & "</td><td>" & FormatTime(intLengthPlayed) & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("File size") & "</td><td>" & FormatFileSize(intFileLength) & "</td><td>" & FormatFileSize(intFileLengthPlayed) & "</td></tr>" & vbcrlf 'strOut = strOut & " <tr><td colspan=""3"">* = " & SDB.Localize("Parts of item played") & "</td></tr>" & vbcrlf strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'Averages Dim intAvgYear Dim intAvgBitrate Dim intAvgRating Dim intTracksPerAlbum Dim intSongsPerGenre Dim intPlayPerDay Dim intPlayedRating Dim intSongsPerArtist Dim intSongsPerYear Dim intSongsPerRating strSQL = "SELECT avg(QryTemp.Year) AS avgYear FROM (SELECT Songs.Year FROM Songs GROUP BY Songs.Year HAVING Songs.Year <> -1) as QryTemp" Set qryStats = SDB.Database.OpenSQL(strSQL) intAvgYear = CCur(NoNull(qryStats.ValueByName("avgYear"),0)) strSQL = "SELECT Avg(SongLength) as AvgLength, Avg(FileLength) as AvgFileLength, Avg(Bitrate) as AvgBitrate FROM Songs" Set qryStats = SDB.Database.OpenSQL(strSQL) intLength = CCur(NoNull(qryStats.ValueByName("AvgLength"),0)) intFileLength = CCur(NoNull(qryStats.ValueByName("AvgFileLength"),0)) intAvgBitrate = CCur(NoNull(qryStats.ValueByName("AvgBitrate"),0)) strSQL = "SELECT Avg(Songs.Rating) AS AvgRating FROM Songs HAVING Songs.Rating <> -1" Set qryStats = SDB.Database.OpenSQL(strSQL) intAvgRating = CCur(NoNull(qryStats.ValueByName("AvgRating"),0)) strSQL = "SELECT Avg(SongLength) as AvgLength, Avg(FileLength) as AvgFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong" Set qryStats = SDB.Database.OpenSQL(strSQL) intLengthPlayed = CCur(NoNull(qryStats.ValueByName("AvgLength"),0)) intFileLengthPlayed = CCur(NoNull(qryStats.ValueByName("AvgFileLength"),0)) strSQL = "Select Avg(CountOfID) AS AVGTracks FROM (" strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID " strSQL = strSQL & "FROM Songs INNER JOIN Albums ON Songs.IDAlbum = Albums.ID " strSQL = strSQL & "GROUP BY Albums.ID)" Set qryStats = SDB.Database.OpenSQL(strSQL) intTracksPerAlbum = CCur(NoNull(qryStats.ValueByName("AVGTracks"),0)) strSQL = "SELECT Avg(CountOfID) AS AVGPlayed FROM (SELECT Count(Songs.ID) AS CountOfID " strSQL = strSQL & "FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong " strSQL = strSQL & "GROUP BY int(Played.PlayDate))" Set qryStats = SDB.Database.OpenSQL(strSQL) intPlayPerDay = CCur(NoNull(qryStats.ValueByName("AVGPlayed"),0)) strSQL = "SELECT Avg(Songs.Rating) AS AvgRatingPlayed FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong HAVING Songs.Rating <> -1" Set qryStats = SDB.Database.OpenSQL(strSQL) intPlayedRating = CCur(NoNull(qryStats.ValueByName("AvgRatingPlayed"),0)) strSQL = "Select Avg(CountOfID) AS AVGGenre FROM (" strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID " strSQL = strSQL & "FROM Songs INNER JOIN Genres ON Songs.Genre = Genres.IDGenre " strSQL = strSQL & "GROUP BY Genres.IDGenre)" Set qryStats = SDB.Database.OpenSQL(strSQL) intSongsPerGenre = CCur(NoNull(qryStats.ValueByName("AVGGenre"),0)) strSQL = "Select Avg(CountOfID) AS AVGArtist FROM (" strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID " strSQL = strSQL & "FROM Songs INNER JOIN Artists ON Songs.IdArtist = Artists.ID " strSQL = strSQL & "GROUP BY Artists.ID)" Set qryStats = SDB.Database.OpenSQL(strSQL) intSongsPerArtist = CCur(NoNull(qryStats.ValueByName("AVGArtist"),0)) strSQL = "Select Avg(CountOfID) AS AVGYear FROM (" strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID " 'strSQL = strSQL & "FROM Songs " strSQL = strSQL & "FROM Songs WHERE Songs.Year <> -1 " strSQL = strSQL & "GROUP BY Songs.Year)" Set qryStats = SDB.Database.OpenSQL(strSQL) intSongsPerYear = CCur(NoNull(qryStats.ValueByName("AVGYear"),0)) strSQL = "Select Avg(CountOfID) AS AVGTracksRating FROM (" strSQL = strSQL & "SELECT Count(Songs.ID) AS CountOfID " 'strSQL = strSQL & "FROM Songs " strSQL = strSQL & "FROM Songs WHERE Songs.Rating <> -1 " strSQL = strSQL & "GROUP BY Songs.Rating)" Set qryStats = SDB.Database.OpenSQL(strSQL) intSongsPerRating = CCur(NoNull(qryStats.ValueByName("AVGTracksRating"),0)) strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""3"">" & SDB.Localize("Averages") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft""><th>" & SDB.Localize("Type") & "</th><th>" & SDB.Localize("Library") & "</th><th>" & SDB.Localize("Played") & "</th></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks per Artist") & "</td><td>" & Round(intSongsPerArtist, 1) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks per Album") & "</td><td>" & Round(intTracksPerAlbum, 1) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks per Genre") & "</td><td>" & Round(intSongsPerGenre, 1) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks per Year") & "</td><td>" & Round(intSongsPerYear, 1) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks per Rating") & "</td><td>" & Round(intSongsPerRating, 1) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Bitrate (kbps)") & "</td><td>" & Round(intAvgBitrate/1000) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Year") & "</td><td>" & Round(intAvgYear) & "</td><td>-</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Tracks played per day") & "</td><td>-</td><td>" & Round(intPlayPerDay, 1) & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Rating") & "</td><td>" & ShowRating(Round(intAvgRating),booForExport) & "</td><td>" & ShowRating(Round(intPlayedRating),booForExport) & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("Length") & " (h:mm:ss)</td><td>" & FormatTime(intLength) & "</td><td>" & FormatTime(intLengthPlayed) & "</td></tr>" & vbcrlf strOut = strOut & " <tr" & Style & "><td>" & SDB.Localize("File size") & "</td><td>" & FormatFileSize(intFileLength) & "</td><td>" & FormatFileSize(intFileLengthPlayed) & "</td></tr>" & vbcrlf strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'Top 10 Artists strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Artists") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT TOP " & intTopCount & " Artists.ID, Artists.Artist, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM Artists INNER JOIN Songs ON Artists.ID = Songs.IDArtist GROUP BY Artists.ID, Artists.Artist ORDER BY Count(Songs.ID) DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & MapXML(qryStats.StringByName("Artist")) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'Top 10 Artists Played strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Artists played") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Artist") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT TOP " & intTopCount & " Artists.ID, Artists.Artist, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM (Artists INNER JOIN Songs ON Artists.ID = Songs.IDArtist) INNER JOIN Played ON Songs.ID = Played.IdSong GROUP BY Artists.ID, Artists.Artist ORDER BY Count(Songs.ID) DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & MapXML(qryStats.StringByName("Artist")) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'Top 10 Albums 'strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"">" & vbcrlf 'strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Top") & " " & intTopCount & " " & SDB.Localize("Albums") & "</th></tr>" & vbcrlf 'strOut = strOut & " <tr class=""aleft"">" & vbcrlf 'strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf 'strOut = strOut & " <th>" & SDB.Localize("Album") & "</th>" & vbcrlf 'strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf 'strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf 'strOut = strOut & " </tr>" & vbcrlf 'strSQL = "SELECT TOP " & intTopCount & " Albums.ID, Artists.Artist, Albums.Album, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM (Albums INNER JOIN Songs ON Albums.ID = Songs.IDAlbum) INNER JOIN Artists ON Albums.IDArtist = Artists.ID WHERE (((Albums.ID)<>0)) GROUP BY Albums.ID, Artists.ID, Artists.Artist, Albums.Album ORDER BY Count(Songs.ID) DESC" 'Set qryStats = SDB.Database.OpenSQL(strSQL) 'While Not qryStats.EOF 'strOut = strOut & " <tr" & Style() & ">" & vbcrlf 'strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf 'strOut = strOut & " <td>" & MapXML(qryStats.StringByName("Artist")) & " - " & MapXML(qryStats.StringByName("Album")) & "</td>" & vbcrlf 'strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf 'strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf 'strOut = strOut & " </tr>" & vbcrlf ' qryStats.Next 'Wend 'strOut = strOut & " </table>" & vbcrlf 'strOut = strOut & " <p/>" & vbcrlf 'Top 10 Albums played strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Albums played") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Album") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT TOP " & intTopCount & " Albums.ID, Artists.ID as ArID, Artists.Artist, Albums.Album, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM ((Albums INNER JOIN Songs ON Albums.ID = Songs.IDAlbum) INNER JOIN Artists ON Albums.IDArtist = Artists.ID) INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (((Albums.ID)<>0)) GROUP BY Albums.ID, Artists.ID, Artists.Artist, Albums.Album ORDER BY Count(Songs.ID) DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & MapXML(qryStats.StringByName("Artist")) & " - " & MapXML(qryStats.StringByName("Album")) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'Top 10 Genres strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Genres") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT TOP " & intTopCount & " Genres.IDGenre, Genres.GenreName, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM Songs INNER JOIN Genres ON Songs.Genre = Genres.IDGenre GROUP BY Genres.IDGenre, Genres.GenreName ORDER BY Count(Songs.ID) DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & MapXML(qryStats.StringByName("GenreName")) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'Top 10 genres played strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Top " & intTopCount & " Genres played") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Genre") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT TOP " & intTopCount & " Genres.IDGenre, Genres.GenreName, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM (Songs INNER JOIN Genres ON Songs.Genre = Genres.IDGenre) INNER JOIN Played ON Songs.ID = Played.IdSong GROUP BY Genres.IDGenre, Genres.GenreName ORDER BY Count(Songs.ID) DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & MapXML(qryStats.StringByName("GenreName")) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'ratings strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Ratings") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM Songs WHERE (((Songs.Rating)<>-1)) GROUP BY Songs.Rating ORDER BY Songs.Rating DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf 'rating played strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><th colspan=""4"">" & SDB.Localize("Ratings played") & "</th></tr>" & vbcrlf strOut = strOut & " <tr class=""aleft"">" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Tracks") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Rating") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("Length") & "</th>" & vbcrlf strOut = strOut & " <th>" & SDB.Localize("File size") & "</th>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf strSQL = "SELECT Songs.Rating, Count(Songs.ID) AS CountOfID, Sum(SongLength) as TotalLength, Sum(FileLength) as TotalFileLength FROM Songs INNER JOIN Played ON Songs.ID = Played.IdSong WHERE (((Songs.Rating)<>-1)) GROUP BY Songs.Rating ORDER BY Songs.Rating DESC" Set qryStats = SDB.Database.OpenSQL(strSQL) While Not qryStats.EOF strOut = strOut & " <tr" & Style() & ">" & vbcrlf strOut = strOut & " <td>" & qryStats.StringByName("CountOfID") & "</td>" & vbcrlf strOut = strOut & " <td>" & ShowRating(qryStats.StringByName("Rating"),booForExport) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatTime(CCur(qryStats.ValueByName("TotalLength"))) & "</td>" & vbcrlf strOut = strOut & " <td>" & FormatFileSize(CCur(qryStats.ValueByName("TotalFileLength"))) & "</td>" & vbcrlf strOut = strOut & " </tr>" & vbcrlf qryStats.Next Wend strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf strOut = strOut & " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">" & vbcrlf strOut = strOut & " <tr><td style='border-bottom-width:0px'>" & vbcrlf strOut = strOut & " " & SDB.Localize("Generated by ") & "<a href='http://www.mediamonkey.com'>MediaMonkey</a>" & SDB.Localize(" on ") & MapXML(FormatDateTime(date(), vbLongDate)) & " " & SDB.Localize("at") & " " & MapXml(FormatDateTime(time(), vbLongTime)) strOut = strOut & " </td></tr>" & vbcrlf strOut = strOut & " </table>" & vbcrlf strOut = strOut & " <p/>" & vbcrlf strOut = strOut & " </body>" & vbcrlf strOut = strOut & "</html>" & vbcrlf BuildReport = strOut End Function